/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Converters;

import core.Emetteur;
import core.NetPaquet;
import core.Recepteur;
import org.jboss.netty.channel.ChannelHandlerContext;

/**
 *
 * @author MOI
 */
public class NettyConverter {
    private ConnectionConverter C;
    private PaquetConverter P;
    private Emetteur E;

    public NettyConverter(ConnectionConverter c, PaquetConverter p, Emetteur e)
    {
        this.C=c;
        this.P=p;
        this.E=e;
    }

   public NetPaquet Convert(Object msg,ChannelHandlerContext ctx)
    {
       NetPaquet N= this.P.convertA(msg);
       N.setSrc(this.C.convertA(ctx));
       return N;
   }
   public void Send(NetPaquet N)
    {
       this.E.send(N);
   }
   public void ConvertAndSend(Object msg,ChannelHandlerContext ctx)
    {
       this.Send(this.Convert(msg, ctx));
   }

}
